package com.spzx.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.product.domain.ProductDetails;
import com.spzx.product.mapper.ProductDetailsMapper;
import com.spzx.product.service.ProductDetailsService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商品sku属性表 服务实现类
 * </p>
 *
 * @author spzx
 * @since 2024-12-19
 */
@Service
public class ProductDetailsServiceImpl extends ServiceImpl<ProductDetailsMapper, ProductDetails> implements ProductDetailsService {

    /**
     * 获取商品详情图片地址
     * @param productId
     * @return
     */
    @Override
    public String[] getDetailsImageUrl(Long productId) {
        LambdaQueryWrapper<ProductDetails> queryWrapper =
                new LambdaQueryWrapper<ProductDetails>()
                        .eq(ProductDetails::getProductId, productId)
                        .select(ProductDetails::getImageUrls);
        ProductDetails productDetails = baseMapper.selectOne(queryWrapper);
/*        if (productDetails == null) {
            return null;
        }*/
        return productDetails.getImageUrls().split(",");
    }
}
